package com.wzp.server;

/**
 * @author zhengpeng.wang
 */
public class FindLengthOfLCIS {

    public int findLengthOfLCIS1(int[] nums) {
        int n = nums.length, max = 1, count = 1;
        for (int i = 0; i < n - 1; i++) {
            count = (nums[i + 1] > nums[i]) ? count + 1 : 1;
            max = Math.max(max, count);
        }
        return max;
    }

    public int findLengthOfLCIS(int[] nums) {
        int rets = 1, left = 0;
        for (int i = 1; i < nums.length; i++) {
            if (nums[i] > nums[i - 1]) {
                rets = Math.max(rets, i - left + 1);
            } else {
                left = i;
            }
        }
        return rets;
    }

    public int findLengthOfLCIS3(int[] nums) {
        int count = 1, max = 0;
        for (int i = 0; i < nums.length - 1; i++) {
            if (nums[i + 1] > nums[i]) {
                count++;
            } else {
                count = 1;
            }
            max = Math.max(max, count);
        }
        return max;
    }

}
